package com.hmusic.mymusic.service.impl;

import com.hmusic.mymusic.service.MsmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

/**
 * 发送邮箱验证码接口实现类
 */
@Service
public class MsmServiceImpl implements MsmService {

    @Autowired
    JavaMailSender javaMailSender;

    /**
     * 发送邮箱验证码方法
     * @param email
     * @param code
     */
    @Override
    public void sendEmail(String email, String code) {
        SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
        simpleMailMessage.setSubject("HMusic音乐网站验证码");
        simpleMailMessage.setText("尊敬的用户，您的邮箱注册验证码为：   "+code+"     有效期为5分钟");
        simpleMailMessage.setTo(email);
        simpleMailMessage.setFrom("858162638@qq.com");
        javaMailSender.send(simpleMailMessage);
    }
}
